#!/bin/bash
#
# Licensed to Jasig under one or more contributor license
# agreements. See the NOTICE file distributed with this work
# for additional information regarding copyright ownership.
# Jasig licenses this file to you under the Apache License,
# Version 2.0 (the "License"); you may not use this file
# except in compliance with the License. You may obtain a
# copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on
# an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#


# 1.64383561643836 seconds/day results in 10 minute years
# 0.821917808 seconds/day results in 5 minute years
# 600 second idle results in files not touched in 1 year to drop off 

SCRIPT_DIR=`dirname $0`

OUTPUT_FILE=$1
shift

echo "Encoding video to $OUTPUT_FILE" >&2

$SCRIPT_DIR/gource.sh "$@" --hide bloom,filenames,mouse -o - | \
    ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -profile:v high -flags +cgop -x264opts bframes=2:keyint=30:min-keyint=1 -crf 1 -threads 0 $OUTPUT_FILE

